unit parametercurvegeneratorformunit;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
  Spin, ButtonPanel, ComCtrls, LCLTranslator;

type

  { TParameterCurveGeneratorForm }

  TParameterCurveGeneratorForm = class(TForm)
    FastGrowthLabel: TLabel;
    SlowGrowthLabel: TLabel;
    ResultButtonPanel: TButtonPanel;
    EndpointValuesGroupBox: TGroupBox;
    GrowthTypeGroupBox: TGroupBox;
    Level1Label: TLabel;
    Level99Label: TLabel;
    Level1Panel: TPanel;
    Level1Panel1: TPanel;
    Level1SpinEdit: TSpinEdit;
    Level99SpinEdit: TSpinEdit;
    GrowthTypeTrackBar: TTrackBar;
    procedure CancelButtonClick(Sender: TObject);
    procedure GrowthTypeTrackBarChange(Sender: TObject);
    procedure Level1SpinEditChange(Sender: TObject);
    procedure Level99SpinEditChange(Sender: TObject);
    procedure OKButtonClick(Sender: TObject);
  private
    ResultWasAccepted: Boolean;
  public
    Level1Value: Integer;
    Level99Value: Integer;
    Smoothness: Integer;
    function ShowChoice(ALevel1Value, ALevel99Value, ASmoothness, MaxVal: Integer): Boolean;
  end;

var
  ParameterCurveGeneratorForm: TParameterCurveGeneratorForm;

implementation

{$R *.lfm}

procedure TParameterCurveGeneratorForm.GrowthTypeTrackBarChange(Sender: TObject
  );
begin
  Smoothness := GrowthTypeTrackBar.Position;
end;

procedure TParameterCurveGeneratorForm.CancelButtonClick(Sender: TObject);
begin
  ResultWasAccepted := False;
  Close
end;

procedure TParameterCurveGeneratorForm.Level1SpinEditChange(Sender: TObject);
begin
  Level1Value := Level1SpinEdit.Value;
end;

procedure TParameterCurveGeneratorForm.Level99SpinEditChange(Sender: TObject);
begin
  Level99Value := Level99SpinEdit.Value;
end;

procedure TParameterCurveGeneratorForm.OKButtonClick(Sender: TObject);
begin
  ResultWasAccepted := True;
  Close
end;

function TParameterCurveGeneratorForm.ShowChoice(ALevel1Value, ALevel99Value,
  ASmoothness, MaxVal: Integer): Boolean;
begin
  ResultWasAccepted := False;

  Level1SpinEdit.MaxValue := MaxVal;
  Level1SpinEdit.Value := ALevel1Value;
  Level99SpinEdit.MaxValue := MaxVal;
  Level99SpinEdit.Value := ALevel99Value;
  GrowthTypeTrackBar.Position := ASmoothness;

  Level1Value := ALevel1Value;
  Level99Value := ALevel99Value;
  Smoothness := ASmoothness;
  ShowModal;

  ShowChoice := ResultWasAccepted;
end;

end.

